package com.fept.msgcore.scheduler.impl;

import com.fept.msgcore.repository.pojo.Device;
import com.fept.msgcore.repository.serviceImpl.DeviceServiceImpl;
import com.fept.msgcore.repository.unit.Page;
import com.fept.msgcore.scheduler.job.impl.ScheduleManagerJob;
import org.quartz.SchedulerException;

import java.util.List;

/**
 * Created by Srma on 2/10/2017.
 */
public class DeviceScheduleManagerJob extends ScheduleManagerJob {

    /**
     * 定时表达式
     */
    @Override
    public String getTimeExpression() {
        return "0/5 * * * * ?";
    }

    @Override
    public void process() throws SchedulerException {
        /**
         * 先执行默认的定时任务管理
         */
        super.process();

        logger.info("*****start of " + this.getJobName() + " job****");

        Page page = new Page();
        int current_size = 0;

        do {
            List<Device> list_device = DeviceServiceImpl.getInstance().selectByPage(page);
            current_size = list_device.size();

            page.setCurrentPage(page.getCurrentPage() + 1);

            logger.info(current_size +"");
        }
        while (current_size == page.getPageSize());


        logger.info("*****end of " + this.getJobName() + " job****");



    }

}
